import App from './App'
// 引入 uView UI
import uView from './uni_modules/vk-uview-ui';
import {
	connectMqtt,
	publishMessage,
	subscribeTopic,
	disconnectMqtt,
	EmitMsg
} from '@/Helper/mqtt_New.js';
import util from './store/Util.js'
import request from './store/request.js'
import { globalState  } from './store/globalState';
import checkLogin  from './store/checkLogin';
// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
	...App
})

// 全局注册 MQTT 方法
Vue.prototype.$connectMqtt = connectMqtt
Vue.prototype.$EmitMsg = EmitMsg
Vue.prototype.$publishMessage = publishMessage
Vue.prototype.$subscribeTopic = subscribeTopic
Vue.prototype.$disconnectMqtt = disconnectMqtt
Vue.prototype.$Util = util
Vue.prototype.$request = request
Vue.prototype.$globalState = globalState
Vue.prototype.$checkLogin  = checkLogin
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	// 全局注册 MQTT 方法
	app.config.globalProperties.$EmitMsg = EmitMsg
	app.config.globalProperties.$connectMqtt = connectMqtt
	app.config.globalProperties.$publishMessage = publishMessage
	app.config.globalProperties.$subscribeTopic = subscribeTopic
	app.config.globalProperties.$disconnectMqtt = disconnectMqtt
	app.config.globalProperties.$Util = util;
	app.config.globalProperties.$request = request;
	app.config.globalProperties.$globalState = globalState;
	app.config.globalProperties.$checkLogin = checkLogin;
	// 使用 uView UI
	app.use(uView)
	return {
		app
	}
}
// #endif